package com.example.server.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
@ComponentScan("com.example.commons")
public class ServerClientAutoConfiguration {

    @Bean
    public ExecutorService executor() {
        return new ThreadPoolExecutor(0, 200, 60L, TimeUnit.SECONDS,
                new SynchronousQueue(), (new ThreadFactoryBuilder()).setNameFormat("netty-biz-handler-%d").build());
    }
}
